package flyweightPattern

/**
 * 棋子工厂是享元工厂,负责创建和管理棋子
 *
 * 因为在下棋时只需要黑白两种棋子,所以只创建了黑白两种棋子
 */
object ChessPieceFactory {
    enum class Type {
        WHITE, BLACK
    }

    private val WHITE = ChessPieceImpl("白色")
    private val BLACK = ChessPieceImpl("黑色")

    fun getChessPiece(type: Type): ChessPiece {
        return when (type) {
            Type.WHITE -> WHITE
            Type.BLACK -> BLACK
        }
    }
}